<template>
  <div>
    <span style="text-align: center">登陆人{{ store.userInfo.U_Name }}</span>
    理财名称：<input type="text" v-model="sdate.L_Name" /> 理财收益:<input
      type="text"
      v-model="sdate.Max"
    />--<input type="text" v-model="sdate.Min" />
    <input type="button" value="查询" @click="Show()" />
    <table class="table">
      <thead>
        <tr>
          <td>理财编号</td>
          <td>理财名称</td>
          <td>理财收益</td>
          <td>最低收益</td>
          <td>理财人数</td>
          <td>操作</td>
        </tr>
      </thead>
      <tbody>
        <tr v-for="a in list">
          <td>{{ a.L_Id }}</td>
          <td>{{ a.L_Name }}</td>
          <td>{{ a.L_Money }}</td>
          <td>{{ a.L_MinMoney }}</td>
          <td>{{ a.L_Munber }}</td>
          <td><input type="button" value="我要购买" @click="go(a.L_Id)" /></td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import { reactive, toRefs, onMounted } from 'vue';
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';
const router = useRouter();
const route = useRoute();

import { useStore } from '../../src/store/user';
const store = useStore();

let data: any = reactive({
  sdate: {
    L_Name: '',
    Max: '',
    Min: ''
  },
  list: {}
});
let { sdate, list } = toRefs(data);

onMounted(() => {
  Show();
});
const Show = () => {
  axios({
    url: 'http://localhost:52089/api/User/Show',
    method: 'get',
    params: sdate.value
  }).then((res) => {
    console.log(res);
    list.value = res.data.data;
  });
};

const go = (L_Id: any) => {
  router.push({
    path: '/gai',
    query: {
      L_Id: L_Id
    }
  });
};
</script>

<style scoped></style>
